package edu.hawaii.ics111.exam;

/**
 * Creates a list of questions for the practice final exam in ICS 111.
 * 
 * @author Branden Ogata
 *
 */

public class InitializeICS111Questions
{
  /**
   * Initializes and returns an array of questions for the practice exam for ICS 111.
   * 
   * @return questions The ExamItem[] containing the questions on the practice exam for ICS 111.
   * 
   */
  
  public static ExamItem[] initializeQuestions()
  {
    ExamItem[] questions = new ExamItem[96];
    int index = 0;
    int number = 1;
    int group = 0;
    
    // Supplementary materials
    final String[] CONDITIONAL_FIRST = new String[] {"if ((x == 2) && (y == 4))",
                                                     "{",
                                                     "  System.out.print(\"Alpha\");",
                                                     "}", 
                                                     "else", 
                                                     "{",
                                                     "  if ((x == 2) || (y == 4))",
                                                     "  {",
                                                     "    System.out.print(\"Beta\");",
                                                     "  }", 
                                                     "  else",
                                                     "  {", 
                                                     "    System.out.print(\"Gamma\");",
                                                     "  }",
                                                     "}"};    
    
    final String[] CONDITIONAL_SECOND = new String[] {"if ((x < 2) || (y >= 4))",
                                                      "{",
                                                      "  System.out.print(\"Alpha\");",
                                                      "}",
                                                      "else if ((x > 2) && (y < 4))",
                                                      "{",
                                                      "  if ((x < 8) || (y > 4))",
                                                      "  {",
                                                      "    System.out.print(\"Beta\");",
                                                      "  }",
                                                      "  else",
                                                      "  {",
                                                      "    System.out.print(\"Gamma\");",
                                                      "  }",
                                                      "}"};
    
    final String[] FOR_FIRST = new String[] {"for (int i = 0; i < 2; i++)",
                                             "{",
                                             "  for (int j = 0; j < 2; j++)",
                                             "  {",
                                             "    System.out.print(i + j);",
                                             "  }",
                                             "}"};
    
    final String[] FOR_SECOND = new String[] {"for (int i = 2; i > 0; i--)",
                                              "{",
                                              "  for (int j = 0; j <= 2; j++)",
                                              "  {",
                                              "    System.out.print(i * j);",
                                              "  }",
                                              "}"};

    final String[] WHILE_FIRST = new String[] {"int count = 0;",
                                               "while (count++ < 4)",
                                               "{",
                                               "  System.out.print(count);",
                                               "}"};

    final String[] WHILE_SECOND = new String[] {"int count = 0;",
                                                "while (++count < 4)",
                                                "{",
                                                "  System.out.print(count);",
                                                "}"};
    
    final String[] WHILE_THIRD = new String[] {"int count = 0;",
                                               "while (count++ <= 4)",
                                               "{",
                                               "  System.out.print(count--);",
                                               "}"};
    
    final String[] CIRCLE = new String[] {"public class Circle",
                                          "{",
                                          "  private double x;",
                                          "  private double y;",
                                          "  private double radius;",
                                          "  public static final double PI = 3.14159;",
                                          "",
                                          "  public Circle(double x, double y)",
                                          "  {",
                                          "    this(x, y, 1);",
                                          "  }",
                                          "",
                                          "  public Circle(double x, double y, double radius)",
                                          "  {",
                                          "    this.x = x;",
                                          "    this.y = y;",
                                          "    this.radius = radius;",
                                          "  }",
                                          "",
                                          "  public double getX()",
                                          "  {",
                                          "    return this.x;",
                                          "  }",
                                          "",
                                          "  public void setX(double x)",
                                          "  {",
                                          "    this.x = x;",
                                          "  }",
                                          "",
                                          "  public double getY()",
                                          "  {",
                                          "    return this.y;",
                                          "  }",
                                          "",
                                          "  public void setY(double y)",
                                          "  {",
                                          "    this.y = y;",
                                          "  }",
                                          "",
                                          "  public double getRadius()",
                                          "  {",
                                          "    return this.radius;",
                                          "  }",
                                          "",
                                          "  public void setRadius()",
                                          "  {",
                                          "    this.radius = radius;",
                                          "  }",
                                          "",
                                          "  public double getArea()",
                                          "  {",
                                          "    return Circle.PI * Math.pow(this.radius, 2);",
                                          "  }",
                                          "",
                                          "  public static double getArea(double radius)",
                                          "  {",
                                          "    return Circle.PI * Math.pow(radius, 2);",
                                          "  }",
                                          "",    
                                          "  public double getCircumference()",
                                          "  {",
                                          "    return 2 * Circle.PI * this.radius;",
                                          "  }",
                                          "",   
                                          "  public static double getCircumference(double radius)",
                                          "  {",
                                          "    return 2 * Circle.PI * radius;",
                                          "  }",  
                                          "",    
                                          "  @Override",
                                          "  public String toString()",
                                          "  {",
                                          "    return String.format(\"[(%.2f,%.2f); r=%.2f]\", " +
                                                                    "this.x, this.y, this.radius);",
                                          "  }",
                                          "}"};
    
    final String[] QUADRILATERALS = new String[] {"interface Shape",
                                                  "  Methods:",
                                                  "    double getArea()",
                                                  "      Returns the area of this Shape.",
                                                  "    double getPerimeter()",
                                                  "      Returns the perimeter of this Shape.",
                                                  "",
                                                  "class Quadrilateral implements Shape",
                                                  "  Fields:",
                                                  "    Point p1",
                                                  "    Point p2",
                                                  "    Point p3",
                                                  "    Point p4",
                                                  "  Constructors:",
                                                  "    Quadrilateral(Point p1, Point p2, " + 
                                                                    "Point p3, Point p4)",
                                                  "      Initializes the points of this " +
                                                        "Quadrilateral.",
                                                  "  Methods:",
                                                  "    Point[] getPoints()",
                                                  "      Returns an array of the points of this " +
                                                        "Quadrilateral.",
                                                  "    double getArea()",
                                                  "      Returns the area of this Quadrilateral.",
                                                  "    double getPerimeter()",
                                                  "      Returns the perimeter of this " + 
                                                        "Quadrilateral.",
                                                  "    static double distance(Point first, " + 
                                                                             "Point second)",
                                                  "      Returns the distance between the given " + 
                                                        "points.",
                                                  "    String toString()",
                                                  "      Returns a String representation.",
                                                  "",
                                                  "class Kite extends Quadrilateral",
                                                  "  Constructors:",
                                                  "    Kite(Point p1, Point p2, " + 
                                                           "Point p3, Point p4)",
                                                  "",
                                                  "class Trapezoid extends Quadrilateral",
                                                  "  Constructors:",
                                                  "    Trapezoid(Point p1, Point p2, " +
                                                                "Point p3, Point p4)",
                                                  "",
                                                  "class Paralellogram extends Trapezoid",
                                                  "  Constructors:",
                                                  "    Parallelogram(Point p1, Point p2, " + 
                                                                    "Point p3, Point p4)",
                                                  "  Methods:",
                                                  "    double getPerimeter()",
                                                  "      Returns the perimeter of this " + 
                                                        "Parallelogram.",
                                                  "",
                                                  "class Rectangle extends Parallelogram",
                                                  "  Constructors:",
                                                  "    Rectangle(Point p1, Point p2, " + 
                                                                "Point p3, Point p4)",
                                                  "  Methods:",
                                                  "    double getArea()",
                                                  "      Returns the area of this Rectangle.",
                                                  "",
                                                  "class Square extends Rectangle",
                                                  "  Constructors:",
                                                  "    Square(Point p1, Point p2, " + 
                                                             "Point p3, Point p4)",
                                                  "  Methods:",
                                                  "    double getArea()",
                                                  "      Returns the area of this Square.",
                                                  "    double getPerimeter()",
                                                  "      Returns the perimeter of this Square.",
                                                  "    String toString()",
                                                  "      Returns a String representation.",
                                                  "",
                                                  "class Rhombus extends Parallelogram",
                                                  "  Constructors:",
                                                  "    Rhombus(Point p1, Point p2," +
                                                              "Point p3, Point p4)"};
    
    final String[] FILE_INPUT = new String[] {"Scanner API:",
                                              "  http://docs.oracle.com/javase/6/docs/api" +
                                                 "/java/util/Scanner.html",
                                              "File API:",
                                              "  http://docs.oracle.com/javase/6/docs/api/" + 
                                                 "java/io/File.html"};
    
    final String[] FILE_OUTPUT = new String[] {"FileWriter API:",
                                               "  http://docs.oracle.com/javase/6/docs/api/" + 
                                                  "java/io/FileWriter.html",
                                               "PrintWriter API:",
                                               "  http://docs.oracle.com/javase/6/docs/api/" + 
                                                  "java/io/PrintWriter.html"};
    
    final String[] EASTERN_CONFERENCE = new String[] {"// ArrayList API available at:",
                                                      "//   http://docs.oracle.com/javase/6/docs/" +
                                                        "api/java/util/ArrayList.html",
                                                      "ArrayList<String> eastTeams = new " + 
                                                        "ArrayList<String>();",
                                                      "eastTeams.add(\"Atlanta Thrashers\");",
                                                      "eastTeams.add(\"Boston Bruins\");",
                                                      "eastTeams.add(\"Buffalo Sabres\");",
                                                      "eastTeams.add(\"Carolina Hurricanes\");",
                                                      "eastTeams.add(\"Florida Panthers\");",
                                                      "eastTeams.add(\"Montreal Canadiens\");",
                                                      "eastTeams.add(\"New Jersey Devils\");",
                                                      "eastTeams.add(\"New York Islanders\");",
                                                      "eastTeams.add(\"New York Rangers\");",
                                                      "eastTeams.add(\"Ottawa Senators\");",
                                                      "eastTeams.add(\"Philadelphia Flyers\");",
                                                      "eastTeams.add(\"Pittsburgh Penguins\");",
                                                      "eastTeams.add(\"Tampa Bay Lightning\");",
                                                      "eastTeams.add(\"Toronto Maple Leafs\");",
                                                      "eastTeams.add(\"Washington Capitals\");",
                                                      "// Question 56 should look at this point",
                                                      "eastTeams.remove(0);",
                                                      "eastTeams.add(\"Winnipeg Jets\")"};
    
    final String[] SORTING = new String[] {"(1 , 8), 4 , 16 , 2 ",
                                           " 1 , 8 , 4 , 16 , 2 ",
                                           "",
                                           " 1 ,(8 , 4), 16 , 2 ",
                                           "(1 , 4), 8 , 16 , 2 ",
                                           " 1 , 4 , 8 , 16 , 2 ",
                                           "",
                                           " 1 , 4 ,(8 , 16), 2 ",
                                           " 1 , 4 , 8 , 16 , 2 ",
                                           "",
                                           " 1 , 4 , 8 ,(16 , 2)",
                                           " 1 , 4 ,(8 , 2), 16 ",
                                           " 1 ,(4 , 2), 8 , 16 ",
                                           "(1 , 2), 4 , 8 , 16 ",
                                           " 1 , 2 , 4 , 8 , 16 "};
    
    // Order of Operations - (index 0)
    questions[index++] = new ExamInstruction("For questions 1-5, type in the result of the " + 
                                             "computation in Java.");
    group = 4;
    
    // Question 1
    questions[index++] = new ExamQuestion(number++, "4 + 12 / 3 * 2",
                                          new String[] {"12"}, -1, group--);
    
    // Question 2
    questions[index++] = new ExamQuestion(number++, "4 + 12 / (3 * 2)",
                                          new String[] {"6"}, -1, group--);    

    // Question 3
    questions[index++] = new ExamQuestion(number++, "4 + (12 / 3) * 2",
                                          new String[] {"12"}, -1, group--);    

    // Question 4
    questions[index++] = new ExamQuestion(number++, "(4 + 12) / 3 * 2",
                                          new String[] {"10"}, -1, group--);    

    // Question 5
    questions[index++] = new ExamQuestion(number++, "(4 + 12 / 3) * 2",
                                          new String[] {"16"}, -1, group--);    
    
    // Conditionals - Group 1 (index 6)
    questions[index++] = new ExamInstruction("For questions 6-8, refer to the supplementary code.");
    group = 2;
    
    questions[index++] = new ExamSupplement("Code for Questions 6-8", 
                                            formatSupplement(CONDITIONAL_FIRST));
    
    // Question 6
    questions[index++] = new ExamQuestion(number++, "What is the expected output to the screen " +
                                                    "if x is 2 and y is 4?", new String[] {"Alpha"},
                                                    -1, group--);
    
    // Question 7
    questions[index++] = new ExamQuestion(number++, "What is the expected output to the screen " +
                                          "if x is 4 and y is 2?", new String[] {"Gamma"}, 
                                          -1, group--);
    
    // Question 8
    questions[index++] = new ExamQuestion(number++, "What is the expected output to the screen " +
                                          "if x is 2 and y is 2?", new String[] {"Beta"}, 
                                          -1, group--);    

    // Conditionals - Group 2 (index 11)
    questions[index++] = new ExamInstruction("For questions 9-11, " + 
                                             "refer to the supplementary code.");
    group = 2;
    
    questions[index++] = new ExamSupplement("Code for Questions 9-11", 
                                            formatSupplement(CONDITIONAL_SECOND));
    
    // Question 9
    questions[index++] = new ExamQuestion(number++, "What is the expected output to the screen " +
                                          "if x is 2 and y is 4?", new String[] {"Alpha"}, 
                                          -1, group--);
    
    // Question 10
    questions[index++] = new ExamQuestion(number++, "What is the expected output to the screen " +
                                          "if x is 4 and y is 2?", new String[] {"Beta"}, 
                                          -1, group--);
    
    // Question 11
    questions[index++] = new ExamQuestion(number++, "What is the expected output to the screen " +
                                          "if x is 8 and y is 1?", new String[] {"Gamma"}, 
                                          -1, group--);
    
    // Loops (index 17)
    // Question 12
    questions[index++] = new ExamSupplement("Code for Question 12", formatSupplement(FOR_FIRST));
    questions[index++] = new ExamQuestion(number++, "What will the code below print " + 
                                          "to the screen?", new String[] {"0112"}, -1);
    
    // Question 13
    questions[index++] = new ExamSupplement("Code for Question 13", formatSupplement(FOR_SECOND));
    questions[index++] = new ExamQuestion(number++, "What will the code below print " + 
                                          "to the screen?", new String[] {"024012"}, -1);
    
    // Question 14
    questions[index++] = new ExamSupplement("Code for Question 14", formatSupplement(WHILE_FIRST));
    questions[index++] = new ExamQuestion(number++, "How many times will the program " + 
                                          "go through the loop below?", new String[] {"3",
                                                                                      "4",
                                                                                      "5",
                                                                                      "Infinite"}, 
                                          1);
    
    // Question 15
    questions[index++] = new ExamSupplement("Code for Question 15", formatSupplement(WHILE_SECOND));
    questions[index++] = new ExamQuestion(number++, "How many times will the program " + 
                                          "go through the loop below?", new String[] {"3",
                                                                                      "4",
                                                                                      "5",
                                                                                      "Infinite"}, 
                                          0);
    
    // Question 16
    questions[index++] = new ExamSupplement("Code for Question 16", formatSupplement(WHILE_THIRD));
    questions[index++] = new ExamQuestion(number++, "How many times will the program " + 
                                          "go through the loop below?", new String[] {"3",
                                                                                      "4",
                                                                                      "5",
                                                                                      "Infinite"}, 
                                          3);
    
    // Question 17
    questions[index++] = new ExamQuestion(number++, "How does a do-while loop differ from other " +
                                          "types of loops in terms of program flow?", 
                                          new String[] {"It uses boolean statements",
                                                        "Its condition must be true " + 
                                                          "on the first iteration",
                                                        "It always runs at least once",
                                                        "It is spelled differently"},
                                          2);
    
    // Type Conversion (index 27)
    questions[index++] = new ExamInstruction("");
    group = 3;
    
    // Question 18
    questions[index++] = new ExamQuestion(number++, "Which of the below is an example " + 
                                          "of assignment conversion?", 
                                          new String[] {"int value = (int) 3.14;",
                                                        "double value = 6.4 + 8;",
                                                        "double value = 4;",
                                                        "A Devils fan becoming a Rangers fan"}, 
                                          2, group--);
    
    // Question 19
    questions[index++] = new ExamQuestion(number++, "Which of the below is an example of casting?",
                                          new String[] {"int value = (int) 3.14;",
                                                        "double value = 6.4 + 8;",
                                                        "double value = 4;",
                                                        "Fishing"},
                                          0, group--);
    
    // Question 20
    questions[index++] = new ExamQuestion(number++, "Which of the below is an example " + 
                                          "of promotion?",
                                          new String[] {"int value = (int) 3.14;",
                                                        "double value = 6.4 + 8;",
                                                        "double value = 4;",
                                                        "e8=Q"},
                                          1, group--);
    
    // Question 21
    questions[index++] = new ExamQuestion(number++, "What is stored in value after " + 
                                          "<code>int value = (int) 3.14;</code>?",
                                          new String[] {"3"}, -1, group--); 
    
    // Constructors (index 32)
    // Question 22
    questions[index++] = new ExamQuestion(number++, "Create a Scanner called keyIn that " + 
                                          "gets input from the keyboard.  Assume that " +
                                          "java.util.Scanner has been imported.",
                                          new String[] {"Scanner#1#keyIn#0,1#=#0,1#new#1#" + 
                                                        "Scanner#0#(#0#System.in#0#)#0#;"}, -1); 
    
    // Question 23
    group = 0;
    questions[index++] = new ExamSupplement("Circle Class", formatSupplement(CIRCLE));
    questions[index++] = new ExamQuestion(number++, "Given the Circle class (see supplementary " + 
                                             "materials), <br />create a Circle called c that " + 
                                             "has the coordinates (1,2) and a radius of 8.<br />" + 
                                             "Assume that the code you write is located <br /> " + 
                                             "in the same folder as the Circle class.", 
                                             new String[] {"Circle#1#c#0,1#=#0,1#new" + 
                                                           "#1#Circle#0#(#0#1#0#," +
                                                           "#0#2#0#,#0#8#0#)#0#;"}, 
                                          -1, group--);
    
    // Instance/Class Variables/Methods - Group 1 (index 35)
    questions[index++] = new ExamInstruction("For questions 24-27, refer to the Circle class " + 
                                             "(see supplementary materials).");
    group = 3;
    
    questions[index++] = new ExamSupplement("Circle Class", formatSupplement(CIRCLE));
    
    // Question 24
    questions[index++] = new ExamQuestion(number++, "Which of the variables listed below is an " + 
                                          "instance variable in the Circle class?",
                                          new String[] {"this.x",
                                                        "PI",
                                                        "Circle",
                                                        "description"},
                                          0, group--);
    
    // Question 25
    questions[index++] = new ExamQuestion(number++, "Which of the variables listed below is a " + 
                                          "class variable in the Circle class?",
                                          new String[] {"this.x",
                                                        "PI",
                                                        "Circle",
                                                        "description"},
                                          1, group--);
    
    // Question 26
    questions[index++] = new ExamQuestion(number++, "Which of the methods listed below is an " + 
                                          "instance method in the Circle class?",
                                          new String[] {"thisIsAnInstanceMethod()",
                                                        "Circle()",
                                                        "getX()",
                                                        "calculateArea(double radius)"},
                                          2, group--);
    
    // Question 27
    questions[index++] = new ExamQuestion(number++, "Which of the methods listed below is a " + 
                                          "class method in the Circle class?",
                                          new String[] {"thisIsAnInstanceMethod()",
                                                        "Circle()",
                                                        "getX()",
                                                        "getArea(double radius)"},
                                          3, group--);
    
    // Instance/Class Variables/Methods - Group 2 (index 41)
    questions[index++] = new ExamInstruction("For questions 28-31, refer to the Circle class " + 
                                             "(see supplementary materials).");
    group = 3;

    questions[index++] = new ExamSupplement("Circle Class", formatSupplement(CIRCLE));
    
    // Question 28
    questions[index++] = new ExamQuestion(number++, "What is the value of the radius of some " + 
                                          "Circle c after the line <code>c.setRadius(3.2)</code>?",
                                          new String[] {"6.4",
                                                        "3",
                                                        "\"3.2\"",
                                                        "3.2"},
                                          3, group--);
    
    // Question 29
    questions[index++] = new ExamQuestion(number++, "What does x refer to in the setX method?",
                                          new String[] {"The constant x",
                                                        "The instance variable x",
                                                        "The local variable x",
                                                        "The static variable x"},
                                          2, group--);
    
    // Question 30
    questions[index++] = new ExamQuestion(number++, "What does this.x refer to in the setX method?",
                                          new String[] {"The constant x",
                                                        "The instance variable x",
                                                        "The local variable x",
                                                        "The static variable x"},
                                          1, group--);
    
    // Question 31
    questions[index++] = new ExamQuestion(number++, "What will <code>Circle.getY()</code> do?",
                                          new String[] {"Produce a compile-time error",
                                                        "Return the value of y",
                                                        "Set the value of y to a default value",
                                                        "Return the value of y for the most " + 
                                                          "recent Circle made"},
                                          0, group--);
    
    // Overloading (index 47)
    questions[index++] = new ExamInstruction("For questions 32 and 33, refer to the Circle class " +
                                             "(see supplementary materials).");
    group = 1;
    
    questions[index++] = new ExamSupplement("Circle Class", formatSupplement(CIRCLE));
    
    // Question 32
    questions[index++] = new ExamQuestion(number++, "What is the value of the instance variable " + 
                                          "radius after the line <br /><code>Circle c = new " + 
                                          "Circle(1.6, 2.56)</code>?", new String[] {"null",
                                                                                     "0",
                                                                                     "1",
                                                                                     "1.0"},
                                          3, group--);
    
    // Question 33
    questions[index++] = new ExamQuestion(number++, "What does <code>Circle.getArea(5.12)" + 
                                          "</code> return?", 
                                          new String[] {"32.1699",
                                                        "82.3550",
                                                        "5.12",
                                                        "Nothing, \u03C0r^2 is invalid because " +
                                                          "pies are round, not square"},
                                          1, group--);
    
    // Overriding (index 51)
    questions[index++] = new ExamInstruction("For question 34 and 35, refer to the supplementary " +
                                             "API below.");
    group = 1;
    
    questions[index++] = new ExamSupplement("Quadrilaterals", formatSupplement(QUADRILATERALS));
    
    // Question 34
    questions[index++] = new ExamQuestion(number++, "Given a Rectangle r, what class is the " + 
                                          "method <code>r.getPerimeter()</code> located in?",
                                          new String[] {"Rectangle",
                                                        "Square",
                                                        "Parallelogram",
                                                        "Quadrilateral"},
                                          2, group--);
    
    // Question 35
    questions[index++] = new ExamQuestion(number++, "Given a Rectangle r, what class is the " + 
                                          "method <code>r.getArea()</code> located in?",
                                          new String[] {"Rectangle",
                                                        "Square",
                                                        "Parallelogram",
                                                        "Quadrilateral"},
                                          0, group--);
    
    // toString (index 55)
    // Question 36
    group = 0;
    questions[index++] = new ExamSupplement("Circle Class", formatSupplement(CIRCLE));
    questions[index++] = new ExamQuestion(number++, "Given the line <code>Circle c = new Circle(" +
                                          "2, 5, 6);</code> (see code below) and its results, " + 
                                          "what will System.out.print(c) print?",
                                          new String[] {"[(2,5); r=6]",
                                                        "[(5.00,2.00); r=6.00]",
                                                        "[(2.0,5.0); r=6.0]",
                                                        "[(2.00,5.00); r=6.00]"},
                                          3, group--);
    
    // Inheritance - Group 1 (index 57)
    questions[index++] = new ExamInstruction("For questions 37-40, " + 
                                             "refer to the supplementary API.");
    group = 3;
    
    questions[index++] = new ExamSupplement("Quadrilaterals", formatSupplement(QUADRILATERALS));
    
    // Question 37
    questions[index++] = new ExamQuestion(number++, "Would the line <code>public class Square " +
                                          "extends Rectangle, Rhombus</code> be legal?  Why?",
                                          new String[] {"Yes, this is an example of " + 
                                                          "multiple inheritance",
                                                        "No, classes in Java may only inherit " +
                                                          "from a single parent class",
                                                        "Yes, Square shares many characteristics " +
                                                          "with Rectangle and Rhombus",
                                                        "No, Square is supposed to be " + 
                                                          "Square-Enix"},
                                          1, group--);

    // Question 38
    questions[index++] = new ExamQuestion(number++, "Given the code <code>Trapezoid t = new " +
                                          "Trapezoid(...);</code>, what would " + 
                                          "<code>t.getArea()</code> return?",
                                          new String[] {"A double containing an address to " + 
                                                          "Trapezoid.getArea()",
                                                        "A double containing the return value " +
                                                          "from Shape.getArea()",
                                                        "A double containing the return value " +
                                                          "from Quadrilateral.getArea()",
                                                        "A double containing the return value " +
                                                          "from Trapezoid.getArea()"},
                                          2, group--);
    
    // Question 39
    questions[index++] = new ExamQuestion(number++, "Which class will the Rhombus class most " +
                                          "directly inherit its toString method from?",
                                          new String[] {"Trapezoid",
                                                        "Parallelogram",
                                                        "Quadrilateral",
                                                        "Object"},
                                          2, group--);
    
    // Question 40
    questions[index++] = new ExamQuestion(number++, "How should the Square class call the " + 
                                          "constructor of its parent class Rectangle?",
                                          new String[] {"this(...)",
                                                        "Rectangle.super(...)",
                                                        "Rectangle(...)",
                                                        "super(...)"},
                                          3, group--);  
    
    // Inheritance - Group 2 (index 63)
    questions[index++] = new ExamInstruction("For questions 41-44, " + 
                                             "refer to the supplementary API.");
    group = 3;

    questions[index++] = new ExamSupplement("Quadrilaterals", formatSupplement(QUADRILATERALS));
    
    // Question 41
    questions[index++] = new ExamQuestion(number++, "How should the Square class call the " +
                                          "getArea method from its parent class Rectangle?",
                                          new String[] {"super.getArea()",
                                                        "Rectangle.getArea()",
                                                        "Square.getArea()",
                                                        "this.getArea()"},
                                          0, group--);
    
    // Question 42
    questions[index++] = new ExamQuestion(number++, "Is the line <code>public class Square " +
                                          "implements Rectangle, Rhombus</code> legal?  Why?",
                                          new String[] {"Yes, it is legal to implement from " +
                                                          "more than one source",
                                                        "No, Rectangle and Rhombus are not " +
                                                          "interfaces",
                                                        "Yes, the methods of Rectangle and " +
                                                          "Rhombus will not shadow each other",
                                                        "No, Rectangle and Rhombus are not " +
                                                          "abstract"},
                                          1, group--);
    
    // Question 43
    questions[index++] = new ExamQuestion(number++, "Is the line <code>public class Triangle " +
                                          "extends Shape</code> legal?  Why?",
                                          new String[] {"Yes, any class can inherit from any " +
                                                          "other class",
                                                        "No, Shape is designed for quadrilaterals",
                                                        "Yes, Shape is not listed as abstract",
                                                        "No, Shape is an interface, not a class"},
                                          3, group--);
    
    // Question 44
    questions[index++] = new ExamQuestion(number++, "Is the line <code>Quadrilateral q = new " + 
                                          "Square(...);</code> legal?  Why?",
                                          new String[] {"Yes, Square is a superclass of " + 
                                                          "Quadrilateral",
                                                        "Yes, Square is a subclass of " + 
                                                          "Quadrilateral",
                                                        "No, a Square instance cannot fit into " +
                                                          "the space reserved for Quadrilateral",
                                                        "No, q is a terrible name for an object"},
                                          1, group--);  

    // Command Line Arguments
    // Question 45
    questions[index++] = new ExamQuestion(number++, "Where does Java store command line arguments?",
                                          new String[] {"ArrayList<String> args in the main method",
                                                        "String[] args in the main method",
                                                        "String[] args as a class variable",
                                                        "String args in the main method"},
                                          1);
    
    // Question 46
    questions[index++] = new ExamQuestion(number++, "How can one determine the number of command " +
                                          "line arguments?", new String[] {"args.size",
                                                                           "args.length",
                                                                           "size(args)",
                                                                           "length(args)"},
                                          1);
    
    // File I/O
    // Question 47
    questions[index++] = new ExamSupplement("File Input Resources", formatSupplement(FILE_INPUT));
    questions[index++] = new ExamQuestion(number++, "Which of the following sets up a Scanner " +
                                          "that will get input from the file input.txt?",
                                          new String[] {"Scanner fileIn = new Scanner(new " + 
                                                          "File(\"input.txt\"));",
                                                        "Scanner fileIn = new Scanner(" + 
                                                          "\"input.txt\");",
                                                        "Scanner fileIn = new File(\"input.txt\");",
                                                        "Scanner fileIn = new Scanner(new " +
                                                          "File(input.txt));"},
                                          0);
    
    // Question 48
    questions[index++] = new ExamSupplement("File Output Resources", formatSupplement(FILE_OUTPUT));
    questions[index++] = new ExamQuestion(number++, "Which of the following sets up a " + 
                                          "PrintWriter that will append output to the file " + 
                                          "output.txt?",
                                          new String[] {"PrintWriter fileOut = new PrintWriter(" +
                                                          "new FileWriter(\"output.txt\", true));",
                                                        "PrintWriter fileOut = new PrintWriter(" +
                                                          "new FileWriter(\"output.txt\", false));",
                                                        "PrintWriter fileOut = new PrintWriter(" +
                                                          "new FileWriter(\"output.txt\", \'a\'));",
                                                        "PrintWriter fileOut = new PrintWriter(" +
                                                          "new FileWriter(\"output.txt\"));"},
                                          0);

    // Scanner (index 75)
    questions[index++] = new ExamInstruction("For questions 49 and 50, use the Scanner created " +
                                             "in the line<br /><code>Scanner input = new " +
                                             "Scanner(System.in);</code>");
    group = 1;
    
    // Question 49
    questions[index++] = new ExamQuestion(number++, "What will <code>input.nextInt()</code> " +
                                          "return if the user types in \"94\"?",
                                          new String[] {"94",
                                                        "94.0",
                                                        "\"94\"",
                                                        "A run-time error"},
                                          0, group--);
    
    // Question 50
    questions[index++] = new ExamQuestion(number++, "What will <code>input.nextInt()</code> " + 
                                          "produce if the user types in \"Rangers\"?",
                                          new String[] {"\"Rangers\"",
                                                        "The ASCII values for each character " +
                                                          "in \"Rangers\"",
                                                        "Nothing",
                                                        "A run-time error"},
                                          3, group--);
    
    // Arrays - Group 1 (index 78)
    // Question 51
    questions[index++] = new ExamQuestion(number++, "What does the line <code>int[] values = " + 
                                          "new int[16];</code> do?",
                                          new String[] {"It creates an array with space for " +
                                                          "sixteen int variables",
                                                        "It creates an array with space for " +
                                                          "seventeen int variables",
                                                        "It creates an array of int variables " +
                                                          "all initialized to 16",
                                                        "It causes a compiler error"},
                                          0);
    
    // Arrays - Group 2 (index 79)
    questions[index++] = new ExamInstruction("For questions 52-54, refer to the line<br /><code>" +
                                             "String[] retired = new String[] {\"Gilbert\", " +
                                             "\"Giacomin\", \"Richter\", \"Messier\", " +
                                             "\"Leetch\", \"Graves\", \"Howell\", \"Bathgate\"};" +
                                             "</code>");
    group = 2;
    
    // Question 52
    questions[index++] = new ExamQuestion(number++, "At what index is \"Leetch\" in the array?",
                                          new String[] {"4"}, -1, group--);
    
    // Question 53
    questions[index++] = new ExamQuestion(number++, "How would you print out the number of " + 
                                          "elements in the array called retired without adding a " +
                                          "following newline?",
                                          new String[] {"System#0#.#0#out#0#.#0#print#0#(#0#" + 
                                                        "retired#0#.#0#length#0#)#0#;"}, 
                                          -1, group--);
    
    // Question 54
    questions[index++] = new ExamQuestion(number++, "What would the line <code>retired[8] = " + 
                                          "\"Potvin\";</code> do?",
                                          new String[] {"Store \"Potvin\" in index 8 of the array",
                                                        "Produce a compile-time error",
                                                        "Produce a run-time error",
                                                        "Wrong New York team; Potvin sucks!"},
                                          2, group--);
    
    // ArrayList (index 83)
    questions[index++] = new ExamInstruction("For questions 55-58, refer to the supplementary " +
                                             "code below.");
    group = 3;
    
    questions[index++] = new ExamSupplement("Eastern Conference NHL Teams", 
                                            formatSupplement(EASTERN_CONFERENCE));
    
    // Question 55
    questions[index++] = new ExamQuestion(number++, "What does the line <code>" +
                                          "ArrayList&#60String&#62 eastTeams = new " + 
                                          "ArrayList&#60String&#62();</code> do?",
                                          new String[] {"Creates an instance of the eastTeam class",
                                                        "Creates an ArrayList that stores String " +
                                                          "instances",
                                                        "Initializes an ArrayList with a null " + 
                                                          "String",
                                                        "Defines a constructor for ArrayList"},
                                          1, group--);
    
    // Question 56
    questions[index++] = new ExamQuestion(number++, "Which of the below does NOT return " +
                                          "\"Washington Capitals\"?",
                                          new String[] {"eastTeams.get(14);",
                                                        "eastTeams.get(eastTeams.indexOf(\"" + 
                                                          "Washington Capitals\"));",
                                                        "eastTeams.get(eastTeams.size() - 1);",
                                                        "eastTeams.get(\"Washington Capitals\");"},
                                          3, group--);
    
    // Question 57
    questions[index++] = new ExamQuestion(number++, "What does the line <code>" + 
                                          "eastTeams.remove(0);</code> do?",
                                          new String[] {"Removes the element at index 0 " + 
                                                          "of eastTeams",
                                                        "Removes and returns the element at " + 
                                                          "index 0 of eastTeams",
                                                        "Removes any elements within eastTeams " +
                                                          "that contain \"0\"",
                                                        "Removes the first 0 elements of " +
                                                          "eastTeams"},
                                          1, group--);
    
    // Question 58
    questions[index++] = new ExamQuestion(number++, "After executing all of the supplementary " +
                                          "code, at what index is the element \"Winnipeg Jets\"?",
                                          new String[] {"14"}, -1, group--);
    
    // Exceptions (index 89)
    // Question 59
    questions[index++] = new ExamQuestion(number++, "How are exceptions caught in Java?",
                                          new String[] {"A throws clause",
                                                        "A try-except block",
                                                        "A try-catch block",
                                                        "A glove"},
                                          2);
    
    // Question 60
    questions[index++] = new ExamQuestion(number++, "Can program flow ever enter more than one " +
                                          "catch block for any given try block?",
                                          new String[] {"Yes, if the conditions for each catch " +
                                                          "are met",
                                                        "Yes, if one is a subclass of the other",
                                                        "Yes, if the second exception is caused " +
                                                          "while attempting to handle the first",
                                                        "No"},
                                          3);
    
    // Miscellaneous (index 91)
    // Question 61
    questions[index++] = new ExamSupplement("Sorting Demonstration", formatSupplement(SORTING));
    questions[index++] = new ExamQuestion(number++, "Given the set of numbers (1, 8, 4, 16, 2), " +
                                          "an algorithm sorts the set as shown below.  What " + 
                                          "sorting algorithm is this?",
                                          new String[] {"Merge Sort",
                                                        "Bubble Sort",
                                                        "Insertion Sort",
                                                        "Selection Sort"},
                                          2);
    
    group = 2;
    
    // Question 62
    questions[index++] = new ExamQuestion(number++, "Given the sorted set of numbers " + 
                                          "(1, 2, 3, 4, 5, 6, 7, 8, 9), <br /> how many " + 
                                          "iterations are necessary to find the element 4 using " +
                                          "binary search?", new String[] {"3",
                                                                          "three"}, -1, group--);
    
    // Question 63
    questions[index++] = new ExamQuestion(number++, "Which of the following is a list of " + 
                                          "usability goals in Human-Computer Interaction " + 
                                          "(as covered in lecture)?",
                                          new String[] {"Ease of installation, ease of use, " +
                                                          "ease of development",
                                                        "Visibility, Feedback, Constraints, " +
                                                          "Consistency, Affordances, Mapping",
                                                        "Visceral, Behavioral, and Reflective " + 
                                                          "Appeal",
                                                        "Effectiveness, Efficiency, Safety, " +
                                                          "Utility, Learnability, Memorability"},
                                          3, group--);
    
    // Question 64
    questions[index++] = new ExamQuestion(number++, "You are taking an open-notes Java " + 
                                          "programming exam when you realize that you do not " + 
                                          "know<br /> the method that inserts an element into an " +
                                          "ArrayList.  This exam is worth 20% of your " +
                                          "grade.<br />What should you do?",
                                          new String[] {"Break down crying",
                                                        "Type in random characters",
                                                        "Design a complex workaround involving " +
                                                          "recursion that will take the " + 
                                                          "instructor weeks to figure out",
                                                        "Look in the Java API"},
                                          3, group--);
    
    return questions;
  }
  
  /**
   * Given an array of String instances, format into a single String of code.
   * Trying to manually insert newlines into code is rather tedious, 
   * so a loop seems like a better alternative.
   * 
   * @param lines The String[] containing the supplementary code.
   * 
   * @return formatted A String containing the same code with newlines between each line. 
   * 
   */
  
  public static String formatSupplement(String[] lines)
  {
    String formatted = "";
    
    for (String line : lines)
    {
      formatted += line + "\n";
    }
    
    return formatted;
  }
  
  /**
   * Given an array of String instances, format into a single HTML-formatted String of code.
   * This is designed for use within questions, which use a JLabel and thus require
   * the use of HTML for newlines, formatting, and such.
   * 
   * @param lines The String[] containing the supplementary code.
   * 
   * @return formatted A String containing the same code with HTML newlines between each line.
   * 
   */
  
  @Deprecated
  public static String formatInQuestionSupplement(String[] lines)
  {
    String formatted = "<code>";
    
    // Convert each line to HTML (spaces, greater/less than, add newlines)
    for (String line : lines)
    {
      line = line.replace(" ", "&nbsp;");
      line = line.replace("<", "&lt");
      line = line.replace(">", "&gt");
      formatted += line + "<br />";
    }
    
    formatted += "</code>";
    
    return formatted;
  }
}
